/*菜单管理相关请求*/

import request from '@/utils/request.ts'
import {
  reqMenuTreeSelectData,
  responseMenuDate,
  responseMenuInfo, RoleMenuTreeselect,
  SysMenu
} from "@/api/system/menu/type.ts";
import { UnwrapRef } from "vue";
import { reqBaseData } from "@/api/type";

enum API {
  MENU_LIST_URL = '/system/menu/list' /*获取全部菜单信息*/,
  MENU_ADD_URL = '/system/menu/add' /*添加菜单*/,
  MENU_EDIT_URL = '/system/menu/edit' /*添加菜单*/,
  MENU_DELETE_URL = '/system/menu/delete' /*添加菜单*/,
  MENU_GET_INFO = '/system/menu/info' /*根据id来获取菜单信息，进行回显*/,
  MENU_TREE_SELECT_URL = '/system/menu/treeSelect' /*获取菜单树*/,
  MENU_EXCLUDE_URL = '/system/menu/list/exclude' /*排除菜单*/,
}

/*进行分页查询获取全部的菜单信息*/
export const reqMenuPageListUrl = (queryTableForm: UnwrapRef<{ menuName: string; status: string }>) => {
  return request.post(API.MENU_LIST_URL, queryTableForm)
}

/*添加菜单*/
export const reqMenuAddUrl = (form: any) => {
  return request({
    url: API.MENU_ADD_URL,
    method: 'post',
    data: form
  })
}

/*修改菜单*/
export const reqMenuEditUrl = (form: any) => {
  return request({
    url: API.MENU_EDIT_URL,
    method: 'put',
    data: form
  })
}

/*删除菜单*/
/*根据id来删除菜单信息*/
export const reqMenuDeleteUrl = (menuId: number) => {
  return request({
    url: API.MENU_DELETE_URL + '/' + menuId,
    method: 'delete',
  })
}



/*根据id来获取菜单信息，进行回显*/
export const getMenuInfoUrl = (menuId: any) => {
  return request.get<any, responseMenuInfo>(API.MENU_GET_INFO + '/' + menuId)
}


/*获取菜单树*/
export const reqMenuTreeSelectUrl = () => {
  return request<string, reqMenuTreeSelectData>({
    url: API.MENU_TREE_SELECT_URL,
    method: 'get'
  })
}

/*排除菜单*/
export const reqMenuExcludeUrl = (menuId: any) => {
  return request.get<any, any>(API.MENU_EXCLUDE_URL + '/' + menuId)
}


// 根据角色ID查询菜单下拉树结构
export const reqRoleMenuTreeselect = (roleId: any) => {
  return request<any, RoleMenuTreeselect>({
    url: '/system/menu/roleMenuTreeselect/' + roleId,
    method: 'get'
  })
}

